<script type="text/javascript" src="<?=base_url()?>resource/js/layer/layer.js"></script>
<script type="text/javascript" src="<?=base_url()?>resource/js/layer/extend/layer.ext.js"></script>
<script type="text/javascript">
    $(function(){
        $("select[data-edit-select]").filterSelect();
    });
    //表单验证
    function tijiao(){
        var name= $.trim($('#name').val());
        var email=$.trim($('#email').val());
        var tel=$.trim($('#tel').val());
        var accdis=$.trim($('#accdis').val());
        var hddis=$.trim($('#hddis').val());
        var freight_dis=$.trim($('#shidis').val());
        var clearing_type=$.trim($('#clearing_type').val());
        var sap_id=$.trim($('#sap_id').val());
        var regemail = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
        if(name==''){
            alert('姓名不能为空');
            return false;
        }
        if(email==''){
            alert('邮箱不能为空');
            return false;
        }
        if(!regemail.test(email)){
            alert('邮箱格式不正确！');
            return false;
        }
        if(clearing_type==0){
            alert('结算类型不能为空');
            return false;
        }
        /*if(sap_id==''){
            alert('sap_id不能为空');
            return false;
        }*/
        if(tel==''){
            alert('电话不能为空');
            return false;
        }
        if(/[\u4e00-\u9fa5]/g.test(tel)){
            alert('电话里不能包含汉字！');
            return false;
        }
        if(accdis==''){
            alert('配件折扣不能为空');
            return false;
        }
        if(hddis==''){
            alert('品牌折扣不能为空');
            return false;
        }
        if(isNaN(accdis)){
            alert('配件折扣必须为数字！');
            return false;
        }else{
            if(accdis > 1){
                alert('配件折扣数字不能大于1！');
                return false;
            }
        }
        if(isNaN(hddis)){
            alert('手工费折扣必须为数字！');
            return false;
        }else{
            if(hddis > 1){
                alert('手工费折扣数字不能大于1！');
                return false;
            }
        }
        if(isNaN(freight_dis) || freight_dis==''){
            alert('运费折扣必须为数字！');
            return false;
        }else{
            if(freight_dis > 1){
                alert('运费折扣数字不能大于1！');
                return false;
            }
        }
    }
    //添加面板缩放
    function shoufang(){
        $('.zslist').toggle();
        $('#bandCk').hide();
        if($('.zslist').css('display')=='none'){
            $('#sz').val("+");
            $('#sf').text("展开添加面板");
            $('#yb').hide();
        }else{
            $('#sz').val("-");
            $('#sf').text("收起添加面板");
            $('#yb').show();
        }
    }
    //修改客户信息
    function xiugai(id,typeId){
        layer.open({
            type: 1,
            title:'客户信息',
            area: ['700px', '750px'], //宽高
            content: $('#clientInfo')
        });
        var index=layer.load(2);
        $.post("<?=blang_url('ajax/ajax/clientInfo')?>",{'id':id},function(data){
            if(data){
                layer.close(index);
                var list=JSON.parse(data);
                var obj=list['clientInfo'];
                var parentList=list['parentList'];
                var typeCK=[];
                var recipientsCK=['电商客户','品牌客户','个人','维修店'];
                var typeText = recipientsCK[obj.type-1];
                $('#id_edit').val(obj.id);
                /*
                typeCK[obj.type]='checked';
                var clientTypeHTML="<input type='radio' disabled  name='type' "+typeCK[1]+" value='1' >电商客户"+
                    "<input type='radio' name='type'  "+typeCK[2]+" value='2' >品牌客户"+
                    "<input type='radio' name='type' "+typeCK[3]+" value='3' >个人"+
                    "<input type='radio' name='type' "+typeCK[4]+" value='4' >维修店";
                 $('#clientType').html(clientTypeHTML);
                */
                var parts_set_html="";
                if(obj.type==1){
                    parts_set_html="<input type='radio' value='1' name='parts_set'>配件自备"+
                                   "<input type='radio' value='2' name='parts_set'>配件自备，可用维保仓"+
                                   "<input type='radio' value='3' name='parts_set'>我们采购";
                    $('#parts_set_tr').show();
                }else if(obj.type==2){
                    parts_set_html="<input type='radio' value='1' name='parts_set'>配件自备"+
                                   "<input type='radio' value='2' name='parts_set'>配件自备，可用维保仓";
                    $('#parts_set_tr').show();
                }else{
                    $('#parts_set_tr').hide();
                }
                $('#parts_set').html(parts_set_html);
                $("input[name='parts_set'][value='"+obj.parts_set+"']").attr("checked",true);
                $('#clientType').html(typeText);
                $('#brand_id_tr').remove();
                if(obj.type=='2') {
                    var BrandTrHTML = "<tr id='brand_id_tr'><th>品牌ID：</th><td><input type='text' name='brand_id' value='" + obj.brand_id + "' size='60'></td></tr>";
                    $('#clientTable tr').eq(1).after(BrandTrHTML);
                }
                $('#name_edit').text(obj.name);
                $('#name_en_edit').text(obj.name_en);
                $('#email_edit').text(obj.email);
                $('#tel_edit').text(obj.tel);
                $('#CurrencyIsoCode_edit').val(obj.CurrencyIsoCode);
                $('#facilityExtent_edit').val(obj.facilityExtent);
                $('#accdis_edit').val(obj.accdis);
                $('#hddis_edit').val(obj.hddis);
                $('#clearing_type_edit').val(obj.clearing_type);
                $('#sap_id_edit').val(obj.sap_id);
                $('#manager_edit').val(obj.manager_id+'_'+obj.manager_name);
                $('#shidis_edit').val(obj.shidis);
                $('#UDID').val(obj.UDID);
                var parent_html="<option value=''>-请选择-</option>";
                for(var i=0;i<parentList.length;i++){
                    parent_html+="<option value='"+parentList[i]['id']+"'>"+parentList[i]['name']+"</option>";
                }
                $('#parent_id').html(parent_html);
                $('#parent_id').val(obj.parent_id);
                /*if(obj.type=='1' || obj.type=='2'){
                    $('#name_edit').prop('readonly',true);
                    $('#email_edit').prop('readonly',true);
                    $('#tel_edit').prop('readonly',true);
                }*/
                recipientsCK[obj.recipients]='checked';
                var jszHtml="<input type='radio' name='recipients' "+recipientsCK[0]+" value='0'>SF"+
                    "<input type='radio' name='recipients' "+recipientsCK[1]+" value='1'>tomrepair";
                $('#jsz').html(jszHtml);
            }
        });
    }
    //添加联系人
    function AddContact(id){
        $('#ContactsInfo').attr('display','block');
        $('#customers_id').val(id);
        layer.open({
            type: 1,
            title:'联系人信息',
            area: ['720px', '500px'], //宽高
            content: $('#ContactsInfo')
        });
    }
    /**
     * 联系人列表
     * @param id
     * @constructor
     */
    function ContactList(id){
        $('#ContactsList').attr('display','block');
        var trHtml='';
        layer.open({
            type: 1,
            title:'联系人列表',
            area: ['1020px', '500px'], //宽高
            content: $('#ContactsList')
        });
        $.post("<?=blang_url('ajax/ajax/ContactList')?>",{'customers_id':id},function(data){
            var ContactList=JSON.parse(data);
            $('.addTr').remove();
            for(var i=0;i<ContactList.length;i++){
                trHtml+="<tr class='addTr' align='center'>" +
                "<td rowspan='2'>"+ContactList[i].fullName+"</td>" +
                "<td rowspan='2'>"+ContactList[i].email+"</td>" +
                "<td rowspan='2'>"+ContactList[i].phone+"</td>" +
                "<td>上门取件:</td>" +
                "<td>"+ContactList[i].dtstreet+"</td>" +
                "<td>"+ContactList[i].dtcity+"</td>" +
                "<td>"+ContactList[i].dtstate+"</td>" +
                "<td>"+ContactList[i].dtname+"</td>" +
                "<td>"+ContactList[i].dtphone+"</td>" +
                "<td>"+ContactList[i].dtzipcode+"</td>" +
                "<td>"+ContactList[i].dtcountry+"</td>" +
                "</tr>" +
                "<tr class='addTr' align='center'>" +
                "<td>收货:</td>" +
                "<td>"+ContactList[i].rvstreet+"</td>" +
                "<td>"+ContactList[i].rvcity+"</td>" +
                "<td>"+ContactList[i].rvstate+"</td>" +
                "<td>"+ContactList[i].rvname+"</td>" +
                "<td>"+ContactList[i].rvphone+"</td>" +
                "<td>"+ContactList[i].rvzipcode+"</td>" +
                "<td>"+ContactList[i].rvcountry+"</td>" +
                "</tr>";
            }
            if(trHtml==''){
                trHtml="<tr align='center' class='addTr'><td colspan='11'><span style='color: #ff0000'>当前客户还没有任何联系人</span></td></tr>";
            }
            $('#ContactsTable').append(trHtml)
        });
    }
    //验证联系人表单
    function ckAddContactsForm(){
        var fullName= $.trim($('#fullName').val());
        var email=$.trim($('#emails').val());
        var phone=$.trim($('#phone').val());
        var dtname=$.trim($('#dtname').val());
        var dtstreet=$.trim($('#dtstreet').val());
        var dtcity=$.trim($('#dtcity').val());
        var dtstate=$.trim($('#dtstate').val());
        var dtzipcode=$.trim($('#dtzipcode').val());
        var dtphone=$.trim($('#dtphone').val());
        var dtcountry=$.trim($('#dtcountry').val());
        var rvname=$.trim($('#rvname').val());
        var rvstreet=$.trim($('#rvstreet').val());
        var rvcity=$.trim($('#rvcity').val());
        var rvstate=$.trim($('#rvstate').val());
        var rvzipcode=$.trim($('#rvzipcode').val());
        var rvphone=$.trim($('#rvphone').val());
        var rvcountry=$.trim($('#rvcountry').val());
        if(fullName==''){
            alert('姓名不能为空！');
            return false;
        }
        if(email==''){
            alert('邮箱不能为空！');
            return false;
        }
        if(phone==''){
            alert('电话不能为空！');
            return false;
        }
        if(dtname==''){
            alert('上门取件姓名不能为空！');
            return false;
        }
        if(dtstreet==''){
            alert('上门取件街道不能为空！');
            return false;
        }
        if(dtcity==''){
            alert('上门取件城市不能为空！');
            return false;
        }
        if(dtstate==''){
            alert('上门取件省份不能为空！');
            return false;
        }
        if(dtzipcode==''){
            alert('上门取件邮编不能为空！');
            return false;
        }
        if(dtphone==''){
            alert('上门取件电话不能为空！');
            return false;
        }
        if(dtcountry==''){
            alert('上门取件城市不能为空！');
            return false;
        }
        if(rvname==''){
            alert('收货姓名不能为空！');
            return false;
        }
        if(rvstreet==''){
            alert('收货街道不能为空！');
            return false;
        }
        if(rvcity==''){
            alert('收货城市不能为空！');
            return false;
        }
        if(rvstate==''){
            alert('收货省份不能为空！');
            return false;
        }
        if(rvzipcode==''){
            alert('收货邮编不能为空！');
            return false;
        }
        if(rvphone==''){
            alert('收货电话不能为空！');
            return false;
        }
        if(rvcountry==''){
            alert('收货国家不能为空！');
            return false;
        }
    }
    /**
     * 类型切换
     */
    function ChangeType(){
        var value  = $('input[name="type"]:checked').val();
        if(value==2){
            $('#bandCk').show();
        }else{
            $('#bandCk').hide();
        }
    }
    function AddWarehouse(name,brand_client_id,chargeOff){
        $('#brand_client_id').val(brand_client_id);
        $('#hx_customers_id').val(brand_client_id);
        $("input[type=radio][name='chargeOff']").attr('checked',false);
        $("input[type=radio][name='chargeOff'][value='" + chargeOff + "']").attr("checked", "checked");
        layer.tab({
            area: ['700px', '350px'],
            tab: [{
                title: '代管仓设置',
                content: $('#warehouseList').html()
            }, {
                title: '核销处理方式',
                content: $('#chargeOffList').html()
            }]
        });
        var index=layer.load(2);
        $.post("<?=blang_url('ajax/ajax/AddWarehouse')?>",{'brand_client_id':brand_client_id},function(data){
            if(data !='') {
                layer.close(index);
                var obj = JSON.parse(data);
                if(obj != ''){
                    for(var i=0;i<obj.length;i++){
                        $('#warehouseTable #code_'+obj[i]['site_id']).val(obj[i]['warehouse_code']);
                        $('#warehouseTable #interior_'+obj[i]['site_id']).prop("checked",obj[i]['warranty_interior']);
                        $('#warehouseTable #external_'+obj[i]['site_id']).prop("checked",obj[i]['warranty_external']);
                        $('#warehouseTable #sell_'+obj[i]['site_id']).prop("checked",obj[i]['sell']);
                    }
                }else{
                    $("input[name='warehouse_code[]']").each(function(){
                        $(this).val('');
                    });
                    $("input[name='warranty_interior[]']").each(function(){
                        $(this).prop('checked',false);
                    });
                    $("input[name='warranty_external[]']").each(function(){
                        $(this).prop('checked',false);
                    });
                    $("input[name='sell[]']").each(function(){
                        $(this).prop('checked',false);
                    });
                }
            }
        });
    }
    /**
     *核销处理方式提交验证
     */
    function hexiao(){
        var val=$('input:radio[name="chargeOff"]:checked').val();
        if(val==null){
            alert("请选择核销处理方式!");
            return false;
        }
    }
</script>

<!--菜单 start-->
<?php $this->load->view('defaults/common/left');?>
<!--菜单 end-->

<div id="content">
    <div class="page-header">
        <div class="container-fluid">
        <h1><?=lang('menu_yhgl')?></h1>
        <?=$this->breadcrumb->generateHTML();?>
        </div>
    </div>
    <div class="container-fluid">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-list"></i>合作客户列表</h3>
            </div>
            <div class="panel-body">
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#tab-general" data-toggle="tab">合作客户列表</a></li>
                    <li class=""><a href="#tab-data" data-toggle="tab">新增客户</a></li>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane active" id="tab-general">
                        <div class="well" style="padding:0 19px;">
                          <div class="row">
                            <form action="<?=blang_url('users/member/ConsumerList')?>" method="post" name="searchform" >
                                <div class="col-sm-4">
                                    <div class="form-group">
                                        <label class="control-label">客户/邮箱/电话</label>
                                        <input class="form-control" type="text" name="keyword" placeholder="客户/邮箱/电话" size="60">
                                    </div>
                                
                                </div>
                                <div class="col-sm-4">
                                    <div class="form-group">
                                        <label class="control-label">客户类型</label>
                                        <select class="form-control" name="type">
                                            <option value="">全部</option>
                                            <option value="1">电商客户</option>
                                            <option value="2">品牌客户</option>
                                            <option value="3">个人</option>
                                            <option value="4">维修店</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <div class="form-group">
                                        <label class="control-label">客户经理</label>
                                        <select class="form-control" name="manager_id" id="manager_id">
                                            <option value="">-请选择-</option>
                                            <option value="38">王继宏</option>
                                            <?php foreach($salesList as $row){?>
                                                <option value="<?=$row['id']?>"><?=$row['name']?></option>
                                            <?php }?>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-12" style="padding-bottom:19px;">
                                     <input class="btn btn-primary pull-right" style="margin: 0 0 0 10px;" type="submit" value="查询">
                                    <a class="btn btn-oms pull-right" style="margin: 0 0 0 10px;" href="<?=blang_url('users/member/ExportCustomer/'.$str.'&ExportType=customer')?>"><i class="fa fa-download"></i>&nbsp;导出SF客户模板</a>
                                    <a class="btn btn-oms pull-right" href="<?=blang_url('users/member/ExportCustomer/'.$str.'&ExportType=contacts')?>"><i class="fa fa-download"></i>&nbsp;导出SF联系人模板</a>
                                </div>
                            </form>
                          </div>
                        </div>
                        <div class="table-responsive">
                           <table class="table table-bordered table-hover oms-table">
                            <thead class="table_thead" >
                            <tr>
                                <th class="text-left">ID</th>
                                <th class="text-left">客户</th>
                                <th class="text-left">英文名</th>
                                <th class="text-left">客户经理</th>
                                <th class="text-left">邮箱</th>
                                <th class="text-right">电话</th>
                                <th class="text-right">客户类型</th>
                                <!--<th>配件折扣</th>
                                <th>手工折扣</th>-->
                                <th class="text-right">结算币种</th>
                                <th class="text-right">余额</th>
                                <!--<th >可透支额度</th>-->
                                <th class="text-right" style="width:10%;">操作</th>
                            </tr>
                            </thead>
                            <?php if($consumerList): foreach ($consumerList as $key=>$row):?>
                            <tr ondblclick="ContactList(<?=$row['id']?>)">
                                <td class="text-left"><?=$row['id']?></td>
                                <td class="text-left" id="name<?=$row['id']?>"><?=$row['name']?></td>
                                <td class="text-left" id="name_cn<?=$row['id']?>"><?=$row['name_en']?></td>
                                <td class="text-left" id="manager_name<?=$row['id']?>"><?=$row['manager_name']?></td>
                                <td class="text-left" id="email<?=$row['id']?>"><?=$row['email']?></td>
                                <td class="text-right" id="tel<?=$row['id']?>"><?=$row['tel']?></td>
                                <td class="text-right" id="type<?=$row['id']?>"><?=$row['typeText']?></td>
                                <!--<td class="text-right" id="accdis<?/*=$row['id']*/?>"><?/*=$row['accdis']*/?></td>
                                <td class="text-right" id="hddis<?/*=$row['id']*/?>"><?/*=$row['hddis']*/?></td>-->
                                <td class="text-right" id="CurrencyIsoCode<?=$row['id']?>"><?=$row['CurrencyIsoCode']?></td>
                                <td class="text-right"><?=$row['Balances']?></td>
                                <!--<td class="text-right" id="facilityExtent<?/*=$row['id']*/?>"><?/*=$row['facilityExtent']*/?></td>-->
                                <td class="text-right">
                                    <a class="btn btn-primary btn-sm" href="javascript:void(0)" id="<?=$row['id']?>" onclick="xiugai(id,<?=$row['type']?>)" title="<?=lang('public_editText')?>"><i class="fa fa-edit"></i></a>
                                    <!--<a href="<?/*=blang_url('users/member/DeleteConsumer/'.$row['id'])*/?>" onclick="return confirm('你确定要删除吗？')">删除</a>-->
                                    <!--<a href="javascript:void(0)" id="<?/*=$row['id']*/?>" onclick="AddContact(id)">新增联系人</a>-->
                                    <?php if($row['type']<=2):?>
                                        <a class="btn btn-primary btn-sm" href="javascript:void(0)" onclick="AddWarehouse('<?=$row['name']?>',<?=$row['id']?>,<?=$row['chargeOff']?:0?>)">属性设置</a>
                                    <?php endif;?>
                                </td>
                            </tr>
                             <?php endforeach; else:?>
                                <tr><th colspan="10" class="emptyNumber"><?=lang('public_mygdsj')?>....</th></tr>
                            <?php endif; ?>
                           
                        </table>
                         <?php if($pageShow):?>
                        <div class="page">
                            <?=$pageShow?>
                        </div>
                        <?php endif;?> 
                        </div>
                    </div>
                    <div class="tab-pane" id="tab-data">
                        <form class="form-horizontal" action="<?=blang_url('users/member/AddConsumer')?>" name="searchform" >
                            <div class="form-group">
                                <label class="col-sm-2 control-label">客户类型</label>
                                <div class="col-sm-10">
                                    <!-- <label class="oms-radio">
                                        <input type="radio" name="type" checked value="1" onclick="ChangeType()">电商客户
                                    </label>
                                    <label class="oms-radio">
                                         <input type="radio" name="type" value="2" onclick="ChangeType()">品牌客户
                                    </label> -->
                                    <label class="oms-radio">
                                      <input type="radio" name="type" value="3" checked onclick="ChangeType()">个人
                                    </label>
                                    <label class="oms-radio">
                                      <input type="radio" name="type" value="4" onclick="ChangeType()">维修店
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">品牌ID</label>
                                <div class="col-sm-10">
                                    <input class="form-control" type="text" name="brand_id" id="brand_id">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">客户</label>
                                <div class="col-sm-10">
                                    <input class="form-control" type="text" name="name" id="name">
                                </div> 
                            </div>
                             <div class="form-group">
                                <label class="col-sm-2 control-label">客户结算类型</label>
                                <div class="col-sm-10">
                                   <select class="form-control" name="clearing_type" id="clearing_type">
                                        <option value="0">-请选择-</option>
                                        <option value="1">授信客户</option>
                                        <option value="2">充值客户</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">英文名</label>
                                <div class="col-sm-10">
                                    <input class="form-control" type="text" name="name_en" id="name_en">
                                </div> 
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">SAPID</label>
                                <div class="col-sm-10">
                                  <input class="form-control" type="text" name="sap_id" id="sap_id">
                                </div> 
                            </div>
                             <div class="form-group">
                                <label class="col-sm-2 control-label">邮箱</label>
                                <div class="col-sm-10">
                                   <input class="form-control" type="text" name="email" id="email">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">客户经理</label>
                                <div class="col-sm-10">
                                    <select class="form-control" name="manager" id="manager">
                                        <option value="">-请选择-</option>
                                        <option value="38_王继宏">王继宏</option>
                                        <?php foreach($salesList as $row){?>
                                            <option value="<?=$row['id'].'_'.$row['name']?>"><?=$row['name']?></option>
                                        <?php }?>
                                    </select>
                                </div> 
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">电话</label>
                                <div class="col-sm-10">
                                    <input class="form-control" type="text" name="tel" id="tel">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">结算币种</label>
                                <div class="col-sm-10">
                                    <select class="form-control" id="CurrencyIsoCode" name="CurrencyIsoCode" disabled >
                                        <option value="CNY">CNY</option>
                                        <option value="EUR">EUR</option>
                                        <option value="USD">USD</option>
                                        <option value="GBP">GBP</option>
                                        <option value="SUR">SUR</option>
                                    </select>
                                </div> 
                            </div>
                             <div class="form-group">
                                <label class="col-sm-2 control-label">透支额度</label>
                                <div class="col-sm-10">
                                  <input class="form-control" type="text" name="facilityExtent">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">配件折扣</label>
                                <div class="col-sm-10">
                                   <input class="form-control" type="text" name="accdis" id="accdis" value="1.00">
                                   <label style="color:#1e91cf;">折扣必须为<=1数字(price*Discount)</label>
                                </div> 
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">手工费折扣</label>
                                <div class="col-sm-10">
                                  <input class="form-control" type="text" name="hddis" id="hddis" value="1.00">
                                  <label style="color:#1e91cf;">折扣必须为<=1数字(price*Discount)</label>
                                </div> 
                            </div>
                             <div class="form-group">
                                <label class="col-sm-2 control-label">运费折扣</label>
                                <div class="col-sm-10">
                                   <input class="form-control" type="text" name="shidis" id="shidis" value="1.00">
                                  <label style="color:#1e91cf;">折扣必须为<=1数字(price*Discount)</label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">接收者</label>
                                <div class="col-sm-10">
                                    <label class="oms-radio">
                                      <input type="radio" name="recipients" checked value="0">SF
                                    </label>
                                    <label class="oms-radio">
                                      <input type="radio" name="recipients"  value="1">tomrepair
                                    </label>
                                </div> 
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"></label>
                                <div class="col-sm-10">
                                    <input  class="btn btn-primary" style="padding:8px 45px;" id="yb" onclick="return tijiao()" type="submit" value="新增客户">
                                </div>
                            </div>
                            
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

<div id="ContactsInfo" style="display: none" class="ct_content" >
    <form action="<?=blang_url('users/member/AddContact')?>" method="post" >
    <table class="tbwd800" id="ContactsInfoTable" cellspacing="0" style="border-collapse: collapse;margin-left: 40px;width: 640px;">
        <tr>
            <td colspan="4"> 姓 名：<input type="text" id="fullName" name="fullName" size="50">
                <input type="hidden" id="customers_id" name="customers_id" size="50">
            </td>
        </tr>
        <tr>
            <td colspan="4"> 邮 箱：<input type="text" id="emails" name="email" size="50"></td>
        </tr>
        <tr>
            <td colspan="4"> 电 话：<input type="text" id="phone" name="phone" size="50"></td>
        </tr>
        <tr align="center">
            <td colspan="2"><span style="color: #009900">上门取件地址</span></td>
            <td colspan="2"><span style="color: #0000ff">收货地址</span></td>
        </tr>
        <tr align="center">
            <td><span style="color: #009900">姓名：</span></td>
            <td><input type="text" name="dtname" id="dtname" size="32"></td>
            <td><span style="color: #0000ff">姓名：</span></td>
            <td><input type="text" name="rvname" id="rvname" size="32"></td>
        </tr>
        <tr align="center">
            <td><span style="color: #009900">街道：</span></td>
            <td><input type="text" id="dtstreet" name="dtstreet" size="32"></td>
            <td><span style="color: #0000ff">街道：</span></td>
            <td><input type="text" id="rvstreet" name="rvstreet" size="32"></td>
        </tr>
        <tr align="center">
            <td><span style="color: #009900">城市：</span></td>
            <td><input type="text" id="dtcity" name="dtcity" size="32"></td>
            <td><span style="color: #0000ff">城市：</span></td>
            <td><input type="text" id="rvcity" name="rvcity" size="32"></td>
        </tr>
        <tr align="center">
            <td><span style="color: #009900">省份：</span></td>
            <td><input type="text" id="dtstate" name="dtstate" size="32"></td>
            <td><span style="color: #0000ff">省份：</span></td>
            <td><input type="text" id="rvstate" name="rvstate" size="32"></td>
        </tr>
        <tr align="center">
            <td><span style="color: #009900">邮编：</span></td>
            <td><input type="text" id="dtzipcode" name="dtzipcode" size="32"></td>
            <td><span style="color: #0000ff">邮编：</span></td>
            <td><input type="text" id="rvzipcode" name="rvzipcode" size="32"></td>
        </tr>
        <tr align="center">
            <td><span style="color: #009900">电话：</span></td>
            <td><input type="text" id="dtphone" name="dtphone" size="32"></td>
            <td><span style="color: #0000ff">电话：</span></td>
            <td><input type="text" id="rvphone" name="rvphone" size="32"></td>
        </tr>
        <tr align="center">
            <td><span style="color: #009900">国家：</span></td>
            <td><input type="text" id="dtcountry" name="dtcountry" size="32"></td>
            <td><span style="color: #0000ff">国家：</span></td>
            <td><input type="text" id="rvcountry" name="rvcountry" size="32"></td>
        </tr>
        <tr align="center">
            <td colspan="4"><input type="submit"  value="添加联系人"></td>
        </tr>
    </table>
    </form>
</div>
<div id="ContactsList" style="display: none" class="ct_content">
    <table class="tbwd800" id="ContactsTable" cellspacing="0" style="border-collapse: collapse;width: 980px;margin-left: 20px;">
        <tr>
            <th>姓名</th>
            <th>邮箱</th>
            <th>电话</th>
            <th>地址</th>
            <th>街道</th>
            <th>城市</th>
            <th>省份</th>
            <th>姓名</th>
            <th>电话</th>
            <th>邮编</th>
            <th>国家</th>
        </tr>
    </table>
</div>
<div id="chargeOffList" style="display: none">
    <div class="ct_content">
        <form action="<?=blang_url('users/member/SetChargeOff')?>">
            <input type="hidden" id="hx_customers_id" name="customers_id">
            <input type="hidden" id="str" name="str" value="<?=$str?>">
            <table class="tbwd800"  cellspacing="0" style="border-collapse: collapse;width: 660px;margin-left: 20px;">
                <tr>
                    <th>核销处理方式:</th>
                    <td>
                        <input type="radio" name="chargeOff" value="1">寄回国内
                        <input type="radio" name="chargeOff" value="2">海外处理
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <input type="submit" onclick="return hexiao()" style="width:100px;" value=" 提 交 ">
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
<div id="warehouseList" style="display: none">
    <div class="ct_content" id="warehouseTable">
        <form action="<?=blang_url('users/member/AddWarehouse')?>">
            <input type="hidden" id="brand_client_id" name="brand_client_id">
            <input type="hidden" id="str" name="str" value="<?=$str?>">
            <table class="tbwd800"  cellspacing="0" style="border-collapse: collapse;width: 660px;margin-left: 20px;" id="warehouseTab">
                <?php foreach($siteList as $val){?>
                    <tr>
                        <th>
                            <?=$val['name_en']?>
                            <input type="hidden" name="site_id[<?=$val['id']?>]" value="<?=$val['id']?>">
                        </th>
                        <td>
                            <input type="text" name="warehouse_code[<?=$val['id']?>]" id="code_<?=$val['id']?>">
                            <input type="checkbox" name="warranty_interior[<?=$val['id']?>]" id="interior_<?=$val['id']?>" value="1"> 保内使用
                            <input type="checkbox" name="warranty_external[<?=$val['id']?>]" id="external_<?=$val['id']?>" value="1"> 保外使用
                            <input type="checkbox" name="sell[<?=$val['id']?>]" id="sell_<?=$val['id']?>" value="1"> <span style="color: #ff0000">不能销售</span>
                        </td>
                    </tr>
                <?php }?>
                <tr>
                    <td colspan="2" align="center">
                        <input type="submit" style="width:100px;" value=" 提 交 ">
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
<div id="clientInfo" style="display: none" class="ct_content">
    <form action="<?=blang_url('users/member/UpdateClientInfo')?>">
        <input type="hidden" id="str" name="str" value="<?=$str?>">
    <table class="tbwd800" id="clientTable"  cellspacing="0" style="border-collapse: collapse;width: 660px;margin-left: 20px;">
        <tr>
            <th width="30%">客户类型：</th>
            <td width="70%" id="clientType">

            </td>
        </tr>
        <tr>
            <th>客户：</th>
            <td>
                <input type="hidden" name="page" value="<?=$page?>">
                <span id="name_edit" name="name"></span>
            </td>
        </tr>
        <tr>
            <th>客户结算类型:</th>
            <td>
                <select name="clearing_type" id="clearing_type_edit">
                    <option value="0">-请选择-</option>
                    <option value="1">授信客户</option>
                    <option value="2">充值客户</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>英文名：</th>
            <td>
                <span id="name_en_edit" name="name_en"></span>
            </td>
        </tr>
        <tr>
            <th>SAPID：</th>
            <Td>
                <input type="text" name="sap_id" id="sap_id_edit" size="60">
            </Td>
        </tr>
        <tr>
            <th>邮箱：</th>
            <td>
                <span id="email_edit" name="email"></span>
            </td>
        </tr>
        <tr>
            <th>客户经理：</th>
            <Td>
                <select name="manager" id="manager_edit">
                    <option value="">-请选择-</option>
                    <option value="38_王继宏">王继宏</option>
                    <?php foreach($salesList as $row){?>
                        <option value="<?=$row['id'].'_'.$row['name']?>"><?=$row['name']?></option>
                    <?php }?>
                </select>
            </Td>
        </tr>
        <tr>
            <th>电话：</th>
            <td>
                <span id="tel_edit" name="tel"></span>
            </td>
        </tr>
        <tr>
            <th>结算币种：</th>
            <td>
                <select id="CurrencyIsoCode_edit" name="CurrencyIsoCode" disabled style="width: 270px;">
                    <option value="CNY">CNY</option>
                    <option value="EUR">EUR</option>
                    <option value="USD">USD</option>
                    <option value="GBP">GBP</option>
                    <option value="SUR">SUR</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>透支额度：</th>
            <td><input type="text" id="facilityExtent_edit" name="facilityExtent" size="60"></td>
        </tr>
        <tr>
            <th>配件折扣：</th>
            <td><input type="text" id="accdis_edit" name="accdis" size="60"></td>
        </tr>
        <tr>
            <th>手工费折扣：</th>
            <td><input type="text" id="hddis_edit" name="hddis" size="60"></td>
        </tr>
        <tr>
            <th>运费折扣：</th>
            <td><input type="text" name="shidis" id="shidis_edit" size="60"></td>
        </tr>
        <tr>
            <th>接收者：</th>
            <td id="jsz">

            </td>
        </tr>
        <tr>
            <th>识别码:</th>
            <td><input type="text" name="UDID" id="UDID" size="60"></td>
        </tr>
        <tr>
            <th>所属客户:</th>
            <td>
                <select  name="parent_id"  id="parent_id" style="width: 270px;">
                    <option value="">-请选择-</option>
                </select>
            </td>
        </tr>
        <tr id="parts_set_tr">
            <th>配件使用规则设置:</th>
            <td id="parts_set">

            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="hidden" name="id" id="id_edit">
                <input type="submit" value=" 提 交 ">
            </td>
        </tr>
    </table>
    </form>
</div>



</div>

